#include <iostream>
using namespace std;

// 选择排序
void selectSort(int a[], int n) {
  for (int i = 0; i < n - 1; i++) {
    int min = i;
    for (int j = i + 1; j < n; j++) {
      if (a[j] < a[min]) {
        min = j;
      }
    }
    if (min != i) {
      int temp = a[i];
      a[i] = a[min];
    }
  }
}
// 冒泡排序
void bubbleSort(int a[], int n) {
  for (int i = n; i > 0; i--) {
    for (int j = 0; j < i; j++) {
      if (a[i] < a[j]) {
        int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
    }
  }
}
int main() {
  // 冒泡排序：BubbleSort
  int a[10] = {0, 2, 4, 6, 5, 7, 3, 8, 1, 9};
  // 打印排序前的数组
  cout << "unsorted: " << endl;
  for (int i = 0; i < 10; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  // 排序
  bubbleSort(a, 10);
  // 打印排序后的数组
  cout << "sorted: " << endl;
  for (int i = 0; i < 10; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}